// ddaadfasdfasdfasdfadsfadsfdsfsssssssvar app = getApp()
const Toast = require('../../dist/toast/toast');
let util = require('../../utils/util.js')
var app = getApp()
Page({
  data: {
    btnShow: false,
    put: true,
    field: {
      Nickname: '',
      uName: 'Dowen',
      uBelonged: '北京分行'
    }
  },
  apply(e) {
    var dataForm = {
      realName: this.data.field.uName,
      realGovernment: this.data.field.uBelonged,
      userId: app.globalData.userid
    }
    console.log(dataForm)
    util.getData('registerUserSecond', dataForm, "POST")
      .then(res => {
        Toast({
          message: '申请成功，等待管理员通过',
          selector: '#zan-toast-test'
        });
      })
  },
  uNameChange(event) {
    let uName = 'field.realName'
    this.setData({
      [uName]: event.detail.value
    })
  },
  uBelongedChange(event) {
    let uBelonged = 'field.uBelonged'
    this.setData({
      [uBelonged]: event.detail.value
    })
  },
  onReady() {
    let Nickname = 'field.Nickname'
    this.setData({
      [Nickname]: app.globalData.userInfo.nickName
    })
    if (!app.state){
      this.setData({
        btnShow: true,
        put: false
      })
    }
  }
});